package GUI.PrincipalGUI;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

import GUI.MainGUI;
import javax.swing.JFormattedTextField;
import javax.swing.SwingConstants;
import javax.swing.JComboBox;

import org.omg.CORBA.Principal;

import controllers.PrincipalController;

@SuppressWarnings("serial")

public class PrincipalWindow extends JPanel  implements ActionListener  {
	private JButton bynExit;
	private JTextField Welcome;
	private JButton btnReports;
	private JButton btnDurationTime;
	private JButton btngetQuestion;
	private JButton btnGetGrade;
	private JButton btnGetExam;
	private MainGUI mainGUI;
	private PrincipalController principalController;
public PrincipalWindow(MainGUI mainGUI){
	super();
	initialize();
}

public PrincipalWindow(PrincipalController principalCtrl) {
		super();
	this.principalController = principalCtrl;
	initialize();

}


private void initialize() {
	setBorder(new TitledBorder(null, "principal manu: ", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	setBackground(SystemColor.info);
	setBounds(0,0,MainGUI.setX,MainGUI.setY);
	setLayout(null);
	
	add(getWelcometext());
	add(getExit());
	add(getBtnReports());
	add(getBtnDurationTime());
	add(GETbtnDeclineRequest());
	add(getbtnGetGrade());
	
	add(getbtnGetExam());
	
	

}
private JButton getbtnGetExam() {
	if (btnGetExam==null)
	{
		btnGetExam= new JButton("get exam");
		btnGetExam.setBounds(160, 328, 161, 23);	
	}return btnGetExam;
	
}



private JButton getExit() {
	if (bynExit==null)
	{
		bynExit = new JButton("EXIT");
		bynExit.setSize(new Dimension(50, 40));
		bynExit.setLocation(415, 414);
		bynExit.setFont(new Font("Microsoft New Tai Lue ", Font.BOLD, 12));
		bynExit.setBorder(BorderFactory.createLineBorder(SystemColor.desktop));
		bynExit.addActionListener(this);}
		return bynExit;
	
}

private JTextField getWelcometext() {
	if (Welcome==null)
	{
		Welcome = new JTextField("WELCOME");
		Welcome.setHorizontalAlignment(SwingConstants.CENTER);
		Welcome.setBackground(new Color(0, 255, 255));
		Welcome.setBounds(-11, 21, 511, 32);
		Welcome.setEditable(false);
		Welcome.setColumns(0);
	}
		
	return Welcome;	
	}

private JButton GETbtnDeclineRequest()
{
	if (btngetQuestion==null)
	{
		btngetQuestion = new JButton("get Questions");
		btngetQuestion.setBounds(160, 284, 161, 23);
		btngetQuestion.addActionListener(this);
	}
	return btngetQuestion;
}


private JButton getBtnReports() {
if (btnReports == null) {
	btnReports = new JButton("get reports");
	btnReports.addActionListener(this);
	btnReports.setBounds(160, 134, 161, 46);
}
return btnReports;
}
private JButton getBtnDurationTime() {
if (btnDurationTime == null) {
	btnDurationTime = new JButton("DurationTime Request");
	btnDurationTime.setBounds(160, 214, 161, 32);
}
return btnDurationTime;
}


private JButton getbtnGetGrade() {
if (btnGetGrade == null) {
	btnGetGrade = new JButton("get grade");
	btnGetGrade.setBounds(160, 370, 161, 23);
	btnGetGrade.addActionListener(this);
}
return btnGetGrade;
}




@Override
public void actionPerformed(ActionEvent e) {
	
		
		if(e.getSource() ==bynExit )	{
		MainGUI.handleprincipalGUI(PrincipalController.EXIT);
	}
		if(e.getSource() ==btnReports )	{
			MainGUI.handleprincipalGUI(PrincipalController.REPORT);
			
		}
		if(e.getSource() ==btngetQuestion)	{
			MainGUI.handleprincipalGUI(PrincipalController.QUESTION);
			
		}
		if(e.getSource() ==btnGetExam )	{
			MainGUI.handleprincipalGUI(PrincipalController.EXAM);
			
			
		}
		
		if(e.getSource() ==btnGetGrade )	{
			MainGUI.handleprincipalGUI(PrincipalController.GRADE);
			
		}
}
}